﻿(function () {
  'use strict';
  var controllerId = 'opus';
  angular.module('ng4model').controller(controllerId, ['common', '$scope', '$routeParams', 'currents', 'datacontext', projects]);

  function projects(common, $scope, $routeParams, currents, datacontext) {
    var getLogFn = common.logger.getLogFn;
    var log = getLogFn(controllerId);
    // store forwarded parameters
    var opusId = $routeParams.id;

    // View Model
    var vm = this;
    vm.title = 'Texts';
    vm.opus = {};

    activate();

    function activate() {
      var promises = [getOpus()];
      common.activateController(promises, controllerId)
          .then(function () { log('Activated Projects View'); });
    }

    function getOpus() {
      return datacontext.getOpus(opusId).then(function (data) {
        currents.opus = data;
        return vm.opus = data;
      });
    }

  }
})();